import React from 'react';
import {inject, observer} from 'mobx-react';
import { toJS } from 'mobx';
import { withRouter } from 'react-router-dom';
import { WhiteSpace , WingBlank , Qrcode , Tools, List ,Flex, InputItem, Button } from 'weaver-mobile';
import * as API from '../../../api/signInfo';

const getLabel = Tools.getLabel;
@inject('viewMeetingStore')
@withRouter
@observer
class SetSignTime extends React.Component{
    constructor(props){
      super(props)
    }
    componentWillMount(){
      const { getDefaultSignBackTime } = this.props.viewMeetingStore;
      getDefaultSignBackTime();
    }

    render(){
    const { signTimeStatus, setSignTimeStatus,toSetSignTime } = this.props.viewMeetingStore;
    const { defaultAllowSignTime, defaultAllowSignBackTime} = signTimeStatus
      return(
    <div className='setSignTime'>
     {toSetSignTime&&<div >
        <List>
            <InputItem
              key='SignIn'
              type='number'
              className="setTime"
              defaultValue={defaultAllowSignTime}
              extra={<div style={{color:'black'}}>{getLabel('514054','分钟可以签到')}</div>}
              placeholder=''
              onChange={value=>{
                setSignTimeStatus({defaultAllowSignTime:value})
              }}
            >{getLabel('514053','会议开始前')}</InputItem>
        </List>
        <List>
          <div className='setsigntime-placeholder'>
            <InputItem
              key='SignIn-placeholder'
              type='number'
              placeholder={getLabel('514150','输入0时，表示不限制签到时间。')}
              disabled={true}
            ></InputItem>
          </div>
        </List>
        <List>
            <InputItem
              key="SignBack"
              type='number'
              className="setTime"
              defaultValue={defaultAllowSignBackTime}
              extra={<div style={{color:'black'}}>{getLabel('509653','分钟后不能签退') }</div>}
              placeholder=''
              onChange={value=>{
                setSignTimeStatus({defaultAllowSignBackTime:value})
              }}
            >{getLabel('509652','会议结束') }</InputItem>
        </List>
        <List>
          <div className='setsigntime-placeholder'>
            <InputItem
              key="SignBack-placeholder"
              type='number'
              placeholder={getLabel('510318','输入0时，表示不限制签退时间。')}
              disabled={true}
            ></InputItem>
          </div>
        </List>
        <Button 
            type='primary' 
            style={{position: "absolute",width: "100%",bottom: 0}}
            disabled={false}
            onClick={()=>{
              this.submit()
            }}
          >{getLabel(30986,"保存")}</Button>
      </div>}
       
    </div>
      
      )
    }
    submit = ()=>{
      const { history } = this.props
      const { signTimeStatus, meetingId } = this.props.viewMeetingStore
      let params = {...signTimeStatus , meetingid:meetingId}
      API.saveDefaultSignBackTime(params).then(res=>{
        if(res&&res.api_status){
          history.go(-1)
        }
      })
    }
}
export default SetSignTime
